package com.hddx;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Secretary implements InvocationHandler {
    private Leader leader;
    public Secretary(Leader leader){
        this.leader = leader;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object invoke = method.invoke(leader, args);
        after();
        return invoke;
    }
    public void before(){
        System.out.println("请问签字/盖章用途是什么？");
    }
    public void after(){
        System.out.println("事情已办妥，请问还有什么需要帮助的？");
    }
    public Object getInstance(){
        return Proxy.newProxyInstance(leader.getClass().getClassLoader(),
                leader.getClass().getInterfaces(),this);
    }
}

